package com.miracle.mvplib.base

import android.os.Bundle
import android.view.LayoutInflater
import androidx.appcompat.app.AppCompatActivity
import androidx.viewbinding.ViewBinding

/**
 * created by miracle on 2022/2/11
 * Desc:使用方法：1.继承此抽象类
 *              2.实现自己契约类Contract类中的View接口
 *              3.实现createPresenter()方法
 */
abstract class BaseMvpActivity<T : ViewBinding, P : IPresenter>(val inflater: (inflater: LayoutInflater) -> T) :
    AppCompatActivity(), IView {
    protected lateinit var viewBinding: T

    protected var mPresenter: P

    init {
        mPresenter = createPresenter()
    }

    abstract fun createPresenter(): P

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        viewBinding = inflater(layoutInflater)
        setContentView(viewBinding.root)
    }
}